<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<!-- RichFaces tag library declaration -->
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich" %>

<rich:panel styleClass="loginForm">
    <rich:panelMenu style="width:200px">
        <rich:panelMenuGroup label="ОТКУДА летим?">
            <h:panelGrid columns="2" styleClass="loginForm">
                <h:outputText value="Страна: "/>
                <rich:comboBox id="countrySelect" defaultLabel="Выберите страну" value="#{locationFromBean.country}"
                               valueChangeListener="#{locationFromBean.countrySelected}"
                               suggestionValues="#{geoPlacesDAO.countriesNames}" immediate="true"
                               directInputSuggestions="true">
                    <a4j:support event="onselect" ajaxSingle="true" reRender="regionSelect, citiesSelect"/>
                </rich:comboBox>

                <h:outputText value="Регион: "/>
                <rich:comboBox id="regionSelect" defaultLabel="Выберите регион" value="#{locationFromBean.region}"
                               disabled="#{empty locationFromBean.regionNames}"
                               valueChangeListener="#{locationFromBean.regionSelected}"
                               suggestionValues="#{locationFromBean.regionNames}" immediate="true"
                               directInputSuggestions="true">
                    <a4j:support event="onselect" ajaxSingle="true" reRender="citiesSelect"/>
                </rich:comboBox>

                <h:outputText value="Город: "/>
                <rich:comboBox id="citiesSelect" defaultLabel="Выберите город" value="#{locationFromBean.city}"
                               disabled="#{empty locationFromBean.citiesNames}"
                               suggestionValues="#{locationFromBean.citiesNames}" immediate="true"
                               directInputSuggestions="true"/>
                <h:outputText value="Вылет: "/>
                <a4j:outputPanel id="calendarDeparture" layout="block" style="width:240px">
                    <rich:calendar locale="RU" datePattern="dd.MM.yyyy hh:mm"
                                   showApplyButton="false" cellWidth="24px" cellHeight="22px"
                                   style="width:230px"/>
                </a4j:outputPanel>

            </h:panelGrid>
        </rich:panelMenuGroup>
        <br/>
        <rich:panelMenuGroup label="КУДА хотим?">
            <h:panelGrid columns="2" styleClass="loginForm">
                <h:outputText value="Страна: "/>
                <rich:comboBox id="countryToSelect" defaultLabel="Выберите страну"
                               valueChangeListener="#{locationToBean.countrySelected}"
                               suggestionValues="#{geoPlacesDAO.countriesNames}"
                               directInputSuggestions="true">
                    <a4j:support event="onselect" ajaxSingle="true" reRender="regionToSelect, countryToSelect"/>
                </rich:comboBox>

                <h:outputText value="Регион: "/>
                <rich:comboBox id="regionToSelect" defaultLabel="Выберите регион"
                               disabled="#{empty locationToBean.regionNames}"
                               valueChangeListener="#{locationToBean.regionSelected}"
                               suggestionValues="#{locationToBean.regionNames}"
                               directInputSuggestions="true">
                    <a4j:support event="onselect" ajaxSingle="true" reRender="citiesToSelect"/>
                </rich:comboBox>

                <h:outputText value="Город: "/>
                <rich:comboBox id="citiesToSelect" defaultLabel="Выберите город"
                               disabled="#{empty locationToBean.citiesNames}"
                               suggestionValues="#{locationToBean.citiesNames}"
                               directInputSuggestions="true"/>
                <h:outputText value="Назад: "/>
                <a4j:outputPanel id="calendarArrival" layout="block" style="width:240px">
                    <rich:calendar locale="RU" datePattern="dd.MM.yyyy hh:mm"
                                   showApplyButton="false" cellWidth="24px" cellHeight="22px"
                                   style="width:230px"/>
                </a4j:outputPanel>

            </h:panelGrid>
        </rich:panelMenuGroup>
    </rich:panelMenu>
    <a4j:commandButton value="Показать рейсы!" style="width:100%" styleClass="modalPanelHeader" ajaxSingle="true"
                       reRender="flights_table">
        <a4j:actionparam name="fromBean" value="#{locationFromBean}" assignTo="#{geoPlacesDAO.fromBean}"/>
        <a4j:actionparam name="toBean" value="#{locationToBean}" assignTo="#{geoPlacesDAO.toBean}"/>
    </a4j:commandButton>
    <br/>
</rich:panel>
